/*
 * servo.h
 *
 *  Created on: Sep 27, 2012
 *      Author: bouchier
 *  Declare class
 */

#ifndef SERVO_H_
#define SERVO_H_
#include <qeservo.h>

class ServoMotor {
private:
	int zero;			// used to tune servos to their mid-point and motors to their stopped point. Nominally 128.
	float scale;		// a scaling factor that converts input range to 0 - 255 after zero is added. Should be 127/maxInput
	float value;		// current speed or direction. Range: -1.0 - +1.0
	int limit;			// used to check whether resulting requested setting exceeds motion limit
	int	motorNum;		// motor number (called index in libqwerk)
	bool reversed;		// whether motor is reversed and increasing rqValue should cause decreasing requested position

public:
	ServoMotor(int num, int setZero, float setScale, int setLimit, bool reversed);
	int set(float setValue);	// returns -1 if it can't do it
	float getRq();		// get the last requested value

private:
	CQEServo &servo;	// the servo reference
};
#endif /* SERVO_H_ */
